package com.rc.saas.tenant.service.printer;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rc.saas.tenant.mapper.printer.ElecPrinterRecordMapper;
import com.rc.saas.tenant.model.printer.ElecPrinterRecord;
import com.rc.saas.tenant.vo.elecPrinter.ElecPrinterRecordResultVo;
import com.rc.saas.tenant.vo.elecPrinter.ElecPrinterRecordSearch;
import com.rc.saas.tenant.vo.printer.PrinterRecordSearch;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Create by Yang on 2021/7/28
 */
@Service
public class ElecPrinterRecordServiceImpl implements ElecPrinterRecordService{


    @Autowired
    private ElecPrinterRecordMapper printerRecordMapper;

    @Override
    public ElecPrinterRecordMapper getMapper() {
        return printerRecordMapper;
    }

    @Override
    public PageInfo<ElecPrinterRecord> selectPageBySearch(PrinterRecordSearch search, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<ElecPrinterRecord> printerRecordList = printerRecordMapper.selectPageBySearch(search);
        return new PageInfo <ElecPrinterRecord>(printerRecordList);
    }

    @Override
    public List <ElecPrinterRecord> selectPageBySearchSize(PrinterRecordSearch search) {
        search.setOffset(search.getOffset()*search.getLimit());
        return printerRecordMapper.selectPageBySearchSize(search);
    }

    @Override
    public void updatePrintCountById(Long id) {
        printerRecordMapper.updatePrintCountById(id);
    }

    @Override
    public PageInfo<ElecPrinterRecordResultVo> listPageElecPrinterRecord(ElecPrinterRecordSearch elecPrinterRecordVO) {
        PageHelper.startPage(elecPrinterRecordVO.getOffset(), elecPrinterRecordVO.getLimit());
        List<ElecPrinterRecordResultVo> elecPrinterRecordResultVOS = printerRecordMapper.listElecPrinterRecord(elecPrinterRecordVO);
        return new PageInfo<ElecPrinterRecordResultVo>(elecPrinterRecordResultVOS);
    }

    @Override
    public List<ElecPrinterRecordResultVo> exportElecPrinterRecord(ElecPrinterRecordSearch elecPrinterRecordVO) {
        return printerRecordMapper.exportElecPrinterRecord(elecPrinterRecordVO);
    }
}
